package com.ruoyi.piliangfahuo.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.piliangfahuo.domain.BatchDelivery;
import com.ruoyi.piliangfahuo.service.IBatchDeliveryService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 批量发货Controller
 * 
 * @author ruoyi
 * @date 2025-09-11
 */
@RestController
@RequestMapping("/piliangfahuo")
public class BatchDeliveryController extends BaseController
{
    @Autowired
    private IBatchDeliveryService batchDeliveryService;

    /**
     * 查询批量发货列表
     */
    @RequiresPermissions("piliangfahuo:piliangfahuo:list")
    @GetMapping("/list")
    public TableDataInfo list(BatchDelivery batchDelivery)
    {
        startPage();
        List<BatchDelivery> list = batchDeliveryService.selectBatchDeliveryList(batchDelivery);
        return getDataTable(list);
    }

    /**
     * 导出批量发货列表
     */
    @RequiresPermissions("piliangfahuo:piliangfahuo:export")
    @Log(title = "批量发货", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BatchDelivery batchDelivery)
    {
        List<BatchDelivery> list = batchDeliveryService.selectBatchDeliveryList(batchDelivery);
        ExcelUtil<BatchDelivery> util = new ExcelUtil<BatchDelivery>(BatchDelivery.class);
        util.exportExcel(response, list, "批量发货数据");
    }

    /**
     * 获取批量发货详细信息
     */
    @RequiresPermissions("piliangfahuo:piliangfahuo:query")
    @GetMapping(value = "/{deliveryId}")
    public AjaxResult getInfo(@PathVariable("deliveryId") Long deliveryId)
    {
        return success(batchDeliveryService.selectBatchDeliveryByDeliveryId(deliveryId));
    }

    /**
     * 新增批量发货
     */
    @RequiresPermissions("piliangfahuo:piliangfahuo:add")
    @Log(title = "批量发货", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BatchDelivery batchDelivery)
    {
        return toAjax(batchDeliveryService.insertBatchDelivery(batchDelivery));
    }

    /**
     * 修改批量发货
     */
    @RequiresPermissions("piliangfahuo:piliangfahuo:edit")
    @Log(title = "批量发货", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BatchDelivery batchDelivery)
    {
        return toAjax(batchDeliveryService.updateBatchDelivery(batchDelivery));
    }

    /**
     * 删除批量发货
     */
    @RequiresPermissions("piliangfahuo:piliangfahuo:remove")
    @Log(title = "批量发货", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deliveryIds}")
    public AjaxResult remove(@PathVariable Long[] deliveryIds)
    {
        return toAjax(batchDeliveryService.deleteBatchDeliveryByDeliveryIds(deliveryIds));
    }
}
